package edu.bw.utils;

import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

public class SqlSessionFactoryUtils {
    private SqlSessionFactoryUtils() {

    }

    public static SqlSessionFactory generateSqlSessionFactory() {
        //1.构建一个输入流,读取SqlMapConfig.xml文件
        InputStream is = SqlSessionFactoryUtils.class.getClassLoader().getResourceAsStream("SqlMapConfig.xml");

        //2.通过核心配置文件构建一个sqlSessionFactory工厂对象
        return new SqlSessionFactoryBuilder().build(is);
    }
}
